<template>
	<el-card>
		<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
			<el-form-item>
				<el-input v-model="state.queryForm.projectCode" placeholder="项目编号" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-button @click="getDataList()">查询</el-button>
			</el-form-item>
			<el-form-item>
				<el-button v-auth="'sys:project:save'" type="primary" @click="addOrUpdateHandle()">新增</el-button>
			</el-form-item>
			<el-form-item>
				<el-button v-auth="'sys:project:delete'" type="danger" @click="deleteBatchHandle()">删除</el-button>
			</el-form-item>
		</el-form>
		<el-table v-loading="state.dataListLoading" :data="state.dataList" border style="width: 100%" @selection-change="selectionChangeHandle">
			<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
			<el-table-column prop="projectCode" label="项目编号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="projectName" label="项目名称" header-align="center" align="center"></el-table-column>
			<el-table-column prop="customerName" label="客户名称" dict-type="user_gender"></el-table-column>
			<el-table-column prop="userName" label="责任人" header-align="center" align="center"></el-table-column>
			<el-table-column prop="startTime" label="开始时间" header-align="center" align="center"></el-table-column>
			<el-table-column prop="endTime" label="结束时间" header-align="center" align="center"></el-table-column>
			<el-table-column prop="projectProgress" label="状态" header-align="center" align="center">
				<template #default="scope">
					<span v-show="scope.row.projectProgress =='100'" class="fontc2">完成</span>
					<span v-show="scope.row.projectProgress <'100'" class="fontcl">进行中</span>
				</template>
			</el-table-column>
			<el-table-column label="操作" fixed="right" header-align="center" align="center" width="300">
				<template #default="scope">
					<el-button v-auth="'sys:project:update'" type="primary" link @click="addOrUpdateHandle(scope.row)">修改</el-button>
					<el-button v-auth="'sys:project:delete'" type="primary" link @click="deleteBatchHandle(scope.row.id)">删除</el-button>
					<el-button v-auth="'sys:project:add'" v-show="scope.row.projectProgress <'100'" type="primary" link @click="proUpdateHandle(scope.row)">进度维护</el-button>
					<el-button v-auth="'sys:project:view'" type="primary" link @click="viewUpdateHandle(scope.row)">进度查看</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			:current-page="state.page"
			:page-sizes="state.pageSizes"
			:page-size="state.limit"
			:total="state.total"
			layout="total, sizes, prev, pager, next, jumper"
			@size-change="sizeChangeHandle"
			@current-change="currentChangeHandle"
		>
		</el-pagination>
		<!-- 弹窗, 新增 / 修改 -->
		<add-or-update ref="addOrUpdateRef" @refresh-data-list="getDataList"></add-or-update>
		<!-- 弹窗, 新增 / 修改 -->
		<viewlist ref="viewlistRef" @refresh-data-list="getDataList"></viewlist>
		<!-- 弹窗, 新增 / 修改 -->
		<addproinfo ref="addproinfoRef" @refresh-data-list="getDataList"></addproinfo>
	</el-card>
</template>

<script setup lang="ts" name="SysUserIndex">
import { useCrud } from '@/hooks'
import { reactive, ref } from 'vue'
import AddOrUpdate from './add-or-update.vue'
import viewlist from './viewlist.vue'
import addproinfo from './addprojectinfo.vue'
import { IHooksOptions } from '@/hooks/interface'
import { ElMessage, UploadProps } from 'element-plus'
const state: IHooksOptions = reactive({
	dataListUrl: '/sys/project/page',
	deleteUrl: '/sys/project',
	queryForm: {
		projectCode: ''
	}
})

const addOrUpdateRef = ref()
const addOrUpdateHandle = (obj?:any) => {
	addOrUpdateRef.value.init(obj)
}
const viewlistRef = ref()
const viewUpdateHandle = (obj?:any) => {
	viewlistRef.value.init(obj)
}
const addproinfoRef = ref()
const proUpdateHandle = (obj?:any) => {
	addproinfoRef.value.init(obj)
}
const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle } = useCrud(state)
</script>

<style lang="scss" scoped>
.fontcl{
	color:red;
}
.fontc2{
	color:green;
}
</style>